package com.pic.mgt.syushin.action;

import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.dao.DuplicateKeyException;

import com.pic.mgt.IgxStatus;
import com.pic.mgt.action.ActionException;
import com.pic.mgt.action.BusinessRecoverAction;
import com.pic.mgt.dao.syushin.ISyushinBusinessMgtDao;
import com.pic.mgt.dao.syushin.ISyushinBusinessTargetActionDao;
import com.pic.mgt.dao.syushin.SyushinBasicBusinessTargetActionInfoBean;
import com.pic.mgt.dao.syushin.SyushinBusinessMgtInfoBean;
import com.pic.mgt.dao.syushin.SyushinBusinessTargetActionDao;
import com.pic.mgt.executer.SimpleConfirmationFileMaker;
import com.pic.mgt.file.io.FileOperation;
import com.pic.mgt.log.IgxLog;
import com.pic.mgt.manager.business.ApInfoBean;
import com.pic.mgt.manager.business.BasicBusinessInfoBean;
import com.pic.mgt.manager.business.BusinessManager;
import com.pic.mgt.monitor.WrongUnitFormatException;
import com.pic.mgt.monitor.parser.ConfirmtaionFileForTxFileParser;
import com.pic.mgt.monitor.parser.FormatParser;
import com.pic.mgt.syushin.SyushinBusinessUnitFactory;
import com.pic.mgt.utils.FilePathUtils;
import com.pic.mgt.utils.IgxFileUtils;

public class SyushinBusinessRecoverActionImpl implements BusinessRecoverAction {
	private String syushinInboxPathStr;
	private File syushinInboxPath;
	private String syushinRealOutboxPathStr;
	private File syushinRealOutboxPath;
	private String syushinBatchTmpPathStr;
	private File syushinBatchTmpPath;
	private ISyushinBusinessMgtDao syushinBusinessMgtDao;
	private FileOperation fileOperation;
	private FormatParser businessNameForBusinessParser;
	private BusinessManager businessManager;
	// (送多方新增)
	private ISyushinBusinessTargetActionDao syushinBusinessTargetActionDao;
	// (送多方新增)
	private FormatParser syushinTerminalIDParser;
	// (送多方新增)
	private String syushinOkMessageSuffix;

	@Override
	public boolean recoverBusiness(String targetFilename) {
		if (null == targetFilename || targetFilename.isEmpty()) {
			// ********************** Log **********************
			IgxLog.messageLog.warn(this,
							"Recovering business failed. Did not provide target file name.");
			// ********************** Log **********************
			
			return false;
		}
		
		
		// ********************** Log **********************
		IgxLog.messageLog.info(this,
						"Starting recover business '{}' preprocess.",
						targetFilename);
		// ********************** Log **********************
		
		// 取得 target file
		File targetFile = new File(this.syushinInboxPath.getAbsolutePath(),
								   targetFilename);
		// 取得 target file 的確認檔
		File confirmationFile = ConfirmtaionFileForTxFileParser.getConfirmationFile(targetFile);
		
		// ----------------------- 以下開始處理  ------------------------------------
		
		try {
			// 先從資料庫中找出該業務記錄
			// throws DataAccessException
			SyushinBusinessMgtInfoBean syushinBusinessMgtInfoBean = null;
			try {
				syushinBusinessMgtInfoBean = this.syushinBusinessMgtDao.findSyushinBusinessMgtInfoByUnitName(targetFilename);
			} catch (DataAccessException e1) {
				// ********************** Log **********************
				IgxLog.messageDetailsLog.error(this, e1.getMessage());
				// ********************** Log **********************
				
				// ********************** Log **********************
				IgxLog.messageLog.error(this,
								"SUDA-278 Recovering business '{}' preprocess occured a database operation error.",
								targetFilename);
				// ********************** Log **********************
				
				throw new ActionException("");
			}
			
			if (null == syushinBusinessMgtInfoBean) {
				// 表示資料庫中沒有組入的記錄
				
				// 確認檔是否存在
				if (!confirmationFile.exists()) {
					// ********************** Log **********************
					IgxLog.messageLog.error(this,
									"SUDA-279 Can't not find confirmation file for business '{}'.",
									targetFile);
					// ********************** Log **********************
					return false;
				}
				
				// 重新讓確認檔案被偵測
				// throws ActionException
				redetectFile(targetFilename, confirmationFile);
			}
			else {
				// 表示資料庫中有組入的記錄
				
				if (syushinBusinessMgtInfoBean.getStatus().equals(IgxStatus.BUSINESS_COMPLETED) ||
					syushinBusinessMgtInfoBean.getStatus().equals(IgxStatus.BUSINESS_BATCH_TMP)) {
					// 上次執行已經是成功的狀態，不需要做 recover
					
					// ********************** Log **********************
					IgxLog.messageLog.warn(this,
									"The last execution status of business '{}' was completive. No need to recover.",
									targetFilename);
					// ********************** Log **********************
					return true; // 回傳true不是false,因為不是發生錯誤.
				}
				else if (syushinBusinessMgtInfoBean.getStatus().equals(IgxStatus.BUSINESS_REDO) ||
						 syushinBusinessMgtInfoBean.getStatus().equals(IgxStatus.BUSINESS_LOADED)) {
					// 上次執行尚停留在 REDO 或 Load 狀態,表示搬移業務檔的動作都還沒開始做,直接讓檔案 redetect 即可
					
					if (syushinBusinessMgtInfoBean.getStatus().equals(IgxStatus.BUSINESS_LOADED)) {
						// 若為 Loaded 狀態必須先更新為 redo 狀態，否則會被當成重覆的業務，不會再做一次
						// throws ActionException
						updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_REDO, syushinBusinessMgtInfoBean.getUnitName());
					}
					
					// throws ActionException
					redetectFile(targetFilename, confirmationFile);
				}
				else {
					// 其它的狀態為 IgxStatus.BUSINESS_EXECUTING 或 IgxStatus.BUSINESS_FAILED二種
					
					if (targetFile.exists()) {
						if (confirmationFile.exists()) {
							// 目標和確認檔案都存在，直接讓檔案被 redetect
							
							// throws ActionException
							updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_REDO, syushinBusinessMgtInfoBean.getUnitName());
							
							// throws ActionException
							redetectFile(targetFilename, confirmationFile);
						}
						else {
							// 目標檔案存在，但確認檔不存在，不做處理(只寫 ERROR LOG)。
							
							// ********************** Log **********************
							IgxLog.messageLog.error(this,
											"SUDA-327 Can't recover business '{}' because of losing confirmation file '{}'.",
											targetFilename, confirmationFile.getAbsolutePath());
							// ********************** Log **********************
						}
					}
					else {
						// 目標檔案不存在
						
						// throws ActionException
						updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_EXECUTING, syushinBusinessMgtInfoBean.getUnitName());
						
						// 取得業務名稱
						String businessName;
						try {
							// throws WrongUnitFormatException
							businessName = (String)this.businessNameForBusinessParser.parse(targetFilename);
						} catch (WrongUnitFormatException e) {
							// ********************** Log **********************
							IgxLog.messageDetailsLog.error(this, e.getMessage());
							// ********************** Log **********************
							
							// ********************** Log **********************
							IgxLog.messageLog.error(this,
									"SUDA-280 Recovering business '{}' preprocess can't parse the name of the business.",
									targetFilename);
							// ********************** Log **********************
							
							// throws ActionException
							updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, syushinBusinessMgtInfoBean.getUnitName());
							
							throw new ActionException("");
						} 
						
						// (送多方刪除)
						// 取得應被搬移至對應目錄下的目標檔和確認檔
						/*File[] fileInfo = getMovedPairFilesBySyushinType(
																targetFilename,
																businessName,
																syushinBusinessMgtInfoBean.getType());
						File movedTargetFile = fileInfo[0];
						File movedConfirmationFile = fileInfo[1];*/
						
						// (送多方刪除)
						// 取得確認檔的暫存檔 (只有 real 的集信業務才會用到；batch 的不會)
						/*File movedTmpConfirmationFile = SimpleConfirmationFileMaker.getTmepConfirmationFile(movedConfirmationFile);*/
						
						if (confirmationFile.exists()) {
							// 目標檔案已不存在，但確認檔存在，所以完成接下來的確認檔產生動作。(real 和 batch 的處理動作不同)
							
							if (syushinBusinessMgtInfoBean.getType().equals(SyushinBusinessUnitFactory.BATCH_SYUSHIN)) {
								// (送多方新增)
								// 取得應被搬移至對應目錄下的目標檔和確認檔
								File[] fileInfo = getMovedPairFilesBySyushinType(targetFilename, businessName);
								File movedTargetFile = fileInfo[0];
								File movedConfirmationFile = fileInfo[1];
								
								// batch 的集信業務 , 要先取得同步再將確認檔搬入 batch tmp 資料匣夾底下
								
								// 同歩的目的是要避免在list要打包的檔案清單同時,又將檔案移入此暫存目錄中。
								BasicBusinessInfoBean basicBusinessInfoBean =
									businessManager.getBasicBusinessInfoBean(businessName);
								synchronized (basicBusinessInfoBean.getBusinessName()) {
									try {
										if (!movedTargetFile.exists()) {
											/*
											 *  batch tmp 資料匣底下目標檔已不存在,表示已被完成打包,便不需要再移確認檔.直接把確認檔刪除。
											 *  
											 *  會發生此種情況主要原因為,batch的目標檔案已經被移入 batch tmp 目錄底下,接著要再把確認檔也
											 *  搬到 batch tmp 目錄底下,但此動作進行到一半時系統 crash , 導致二邊都有確認檔存在。因此在打
											 *  包動作進行時有湞測到該確檔案，便會打包該業務的 batch 目標檔案，被打包完後會被刪除。
											 */
											// throws IOException
											this.fileOperation.deleteFile(confirmationFile);
										}
										else {
											// throws IOException
											this.fileOperation.moveFileToFile(confirmationFile, movedConfirmationFile);
										}
									} catch (IOException e1) {
										// ********************** Log **********************
										IgxLog.messageDetailsLog.error(this, e1.getMessage());
										// ********************** Log **********************
										
										// ********************** Log **********************
										IgxLog.messageLog.error(this,
												"SUDA-281 Recovering business '{}' preprocess occured an I/O error in processing file '{}'.",
												syushinBusinessMgtInfoBean.getUnitName(), confirmationFile.getAbsolutePath());
										// ********************** Log **********************
										
										// throws ActionException
										updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, syushinBusinessMgtInfoBean.getUnitName());
										
										throw new ActionException("");
									}
								}
							}
							else if (syushinBusinessMgtInfoBean.getType().equals(SyushinBusinessUnitFactory.REAL_SYUSHIN)) {
								// real 的集信業務 
								
								// (送多方新增)
								try {
									List<ApInfoBean> apInfoBeanList = this.businessManager.getBasicBusinessInfoBean(businessName).getSyushinBusinessApList();
									synchronized(apInfoBeanList) {
										for (ApInfoBean apInfoBean : apInfoBeanList) {
											// 取得應被搬移至對應目錄下的目標檔,確認檔,確認暫存檔和交易檔的訊息檔
											File movedTargetFile = new File(apInfoBean.getApFolder().getAbsolutePath(), targetFilename);
											File movedConfirmationFile = ConfirmtaionFileForTxFileParser.getConfirmationFile(movedTargetFile);
											File movedTmpConfirmationFile = SimpleConfirmationFileMaker.getTmepConfirmationFile(movedConfirmationFile);
											File messageFileForTxFile = getMessageFileForTxFile(movedTargetFile);
											
											if (!movedConfirmationFile.exists()) {
												if (!messageFileForTxFile.exists()) {
													SyushinBasicBusinessTargetActionInfoBean syushinBasicBusinessTargetActionInfoBean = 
															this.syushinBusinessTargetActionDao.findSyushinBusinessTargetActionInfoByFileNameAndApName(
																	targetFile.getName(), apInfoBean.getApName());
													if (null == syushinBasicBusinessTargetActionInfoBean ||
														null == syushinBasicBusinessTargetActionInfoBean.getLastTransactionTime() ||
														(syushinBasicBusinessTargetActionInfoBean.getCreatingTime().after(syushinBasicBusinessTargetActionInfoBean.getLastTransactionTime()))) {
														/*
														 *  訊息檔不見,代表有可能檔案已經被取走。而如果檔案是被取走的情況下，以上情況不會成立，以上情況只要有一個成立，
														 *  表示檔案並不是被取走了，而是該 AP Folder 還沒有完成複製動作。
														 */
														if (movedTargetFile.exists()) {
															/*
															 * 如果交易的檔案存在，才表示該業務當時是有要複製給該 AP Folder的；如果交易檔不存在，表示當時
															 * 業務本來就沒有要複製給該 AP Folder，所以也不需要完成接下來的動作。
															 */
															
															// 執行剩下來還未完成的動作
															
															// 新增資料至DB (syushin_target_action)
															insertSyushinTargetAction(
																				targetFile.getName(),
																				(String)this.syushinTerminalIDParser.parse(confirmationFile.getName()),
																				targetFile.getName(),
																				syushinBusinessMgtInfoBean.getTargetFilesize(),
																				apInfoBean.getApName());
															
															// 建立OK檔
															doConfirmationFileGenerationAction(
																				targetFile.getName(),
																				confirmationFile,
																				movedTmpConfirmationFile,
																				movedConfirmationFile);
														}
													}
													else {
														// 表示該 AP 目錄的交易檔已經被取走了。
													}
												}
												else {
													// 訊息交易檔存在，表示該 AP 目錄已經有作完了，並且正在被MessageExecuter處理中，所以才會有確認檔不存在的狀況，是正常的。
												}
											}
										}
									}
									this.fileOperation.deleteFile(confirmationFile);
								} catch (DataAccessException e) {
									// ********************** Log **********************
									IgxLog.messageDetailsLog.error(this, e.getMessage());
									// ********************** Log **********************
									
									// ********************** Log **********************
									IgxLog.messageLog.error(this,
													"SUDA-278 Recovering business '{}' preprocess occured a database operation error.",
													targetFilename);
									// ********************** Log **********************
									
									// throws ActionException
									updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, syushinBusinessMgtInfoBean.getUnitName());
									
									throw new ActionException("");
								} catch (WrongUnitFormatException e) {
									// ********************** Log **********************
									IgxLog.messageDetailsLog.error(this, e.getMessage());
									// ********************** Log **********************
									
									// ********************** Log **********************
									IgxLog.messageLog.error(this,
											"SUDA-345 Recovering business '{}' preprocess can't parse the terminal id of the business.",
											targetFilename);
									// ********************** Log **********************
									
									// throws ActionException
									updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, syushinBusinessMgtInfoBean.getUnitName());
									
									throw new ActionException("");
								} catch (IOException e) {
									// ********************** Log **********************
									IgxLog.messageDetailsLog.error(this, e.getMessage());
									// ********************** Log **********************
									
									// ********************** Log **********************
									IgxLog.messageLog.error(this,
											"SUDA-281 Recovering business '{}' preprocess occured an I/O error in processing file '{}'.",
											syushinBusinessMgtInfoBean.getUnitName(), confirmationFile.getAbsolutePath());
									// ********************** Log **********************
									
									// throws ActionException
									updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, syushinBusinessMgtInfoBean.getUnitName());
									
									throw new ActionException("");
								}
								
								// (送多方刪除)
								/*// 把確認檔產生至對應的目錄底下
								// throws ActionException
								doConfirmationFileGenerationAction(
												   syushinBusinessMgtInfoBean.getUnitName(),
												   confirmationFile,
												   movedTmpConfirmationFile,
												   movedConfirmationFile);*/
							}
						}
						else {
							// (送多方新增) (新增下行的註解)
							// 不需作處理了
							
							// (送多方刪除)
							/*
							 *  目標檔案已不存在，確認檔也不存在，代表二個檔案已經被搬移到對應的目錄
							 *  底下。必須針對real的集信(batch 的不用)，去判斷對應的目錄底下，只否有完成最後將暫存檔更名為確認檔檔
							 *  名的動作，若沒有則接著完成，最後再更新資料庫狀態。
							 */
							
							/*if (syushinBusinessMgtInfoBean.getType().equals(SyushinBusinessUnitFactory.REAL_SYUSHIN)) {
								if (movedTmpConfirmationFile.exists()) {
									// 確認暫存檔存在,表示還沒完成 rename 動作,完成之.
									// throws ActionException
									doFileRenameAction(syushinBusinessMgtInfoBean.getUnitName(),
													   movedTmpConfirmationFile,
													   movedConfirmationFile);
								}
								else {
									// 確認暫存檔不存在,表示已完成 rename 動作，不須再做其它動作
								}
							}*/
						}
						
						// 做完!更新資料庫為完成狀態
						if (syushinBusinessMgtInfoBean.getType().equals(SyushinBusinessUnitFactory.REAL_SYUSHIN)) {
							// 更新資料庫狀態
							// throws DataAccessException
							updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_COMPLETED,
																  syushinBusinessMgtInfoBean.getUnitName());
						}
						else if (syushinBusinessMgtInfoBean.getType().equals(SyushinBusinessUnitFactory.BATCH_SYUSHIN)) {
							// 更新資料庫狀態
							// throws DataAccessException
							updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_BATCH_TMP,
																  syushinBusinessMgtInfoBean.getUnitName());
						}
					}
				}
			}
		} catch (ActionException e) {
			// ********************** Log **********************
			IgxLog.messageLog.error(this,
				"SUDA-282 Recovering business '{}' preprocess failed.",
				targetFilename);
		// ********************** Log **********************
			
		return false;
		}
		
		// ********************** Log **********************
		IgxLog.messageLog.info(this,
						"Recovering business '{}' preprocess completed.",
						targetFilename);
		// ********************** Log **********************
		
		return true;
	}
	
	// (送多方新增)
	private void insertSyushinTargetAction(String unitName, String terminalId, String targetFilename, long targetFileLen, String apName)
		throws DataAccessException {
		Map<String, Object> insertValuesMap = new HashMap<String, Object>();
		insertValuesMap.put(SyushinBusinessTargetActionDao._unitName, unitName);
		insertValuesMap.put(SyushinBusinessTargetActionDao._terminalId, terminalId);
		insertValuesMap.put(SyushinBusinessTargetActionDao._fileName, targetFilename);
		insertValuesMap.put(SyushinBusinessTargetActionDao._fileSize, targetFileLen);
		insertValuesMap.put(SyushinBusinessTargetActionDao._apName, apName);
		
		try {
			this.syushinBusinessTargetActionDao.insertBasic(insertValuesMap);
		} catch (DuplicateKeyException e) {
			this.syushinBusinessTargetActionDao.updateCreatingTimeByFilenameAndApName(
					new Timestamp(new Date().getTime()), targetFilename, apName);
		}
	}
	
	private void updateSyushinBusinessStatusByUnitName(String status, String unitName)
	throws ActionException {
		// throws DataAccessException
		try {
			this.syushinBusinessMgtDao.updateStatusByUnitName(status, unitName);
		} catch (DataAccessException e) {
			// ********************** Log **********************
			IgxLog.messageDetailsLog.error(this, e.getMessage());
			// ********************** Log **********************
			
			// ********************** Log **********************
			IgxLog.messageLog.error(this,
					"SUDA-278 Recovering business '{}' preprocess occured a database operation error.",
							unitName);
			// ********************** Log **********************
			
			throw new ActionException("");
		}
	}
	
	/**
	 * 依據給定的來源確認檔,目的暫存確認檔和目的確認檔，會將來源確認檔複製至與目的確認檔相同的目錄下，並命名成為暫存檔名。
	 * 搬完後，再將此暫存檔名命名回正確的確認檔檔名。
	 * @param unitName
	 * @param srcConfirmationFile
	 * @param srcTmpConfirmationFile
	 * @param destConfirmationFile
	 * @throws ActionException
	 */
	private void doConfirmationFileGenerationAction(String unitName,
													File srcConfirmationFile,
													File destTmpConfirmationFile,
													File destConfirmationFile) throws ActionException {
		// (送多方修改) (修改註解內容)
		// 將 File OK 檔複製 syushin outbox real 底下,並先命名為暫存檔名
		try {
			// (送多方修改)
			this.fileOperation.copyFileToFile(srcConfirmationFile,
									          destTmpConfirmationFile);
		} catch (IOException e1) {
			// ********************** Log **********************
			IgxLog.messageDetailsLog.error(this, e1.getMessage());
			// ********************** Log **********************
			
			// (送多方修改) (修改 Log 內容)
			// ********************** Log **********************
			IgxLog.messageLog.error(this,
					"SUDA-283 Recovering business '{}' preprocess occured an I/O error in copying file '{}'.",
					unitName, destConfirmationFile.getAbsolutePath());
			// ********************** Log **********************
			
			// throws ActionException
			updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, unitName);
			
			throw new ActionException("");
		}
		
		// 將暫存的 File Ok 檔 rename 為正確的檔名
		// throws ActionException
		doFileRenameAction(unitName, destTmpConfirmationFile, destConfirmationFile);
	}
	
	private void doFileRenameAction(String unitName, File srcFile, File destFile) throws ActionException {
		try {
			this.fileOperation.moveFileToFile(srcFile,
											  destFile);
		} catch (IOException e1) {
			// ********************** Log **********************
			IgxLog.messageDetailsLog.error(this, e1.getMessage());
			// ********************** Log **********************
			
			// ********************** Log **********************
			IgxLog.messageLog.error(this,
					"SUDA-284 Recovering business '{}' preprocess occured an I/O error in renaming file '{}'.",
					unitName, srcFile.getAbsolutePath());
			// ********************** Log **********************
			
			// throws ActionException
			updateSyushinBusinessStatusByUnitName(IgxStatus.BUSINESS_FAILED, unitName);
			
			throw new ActionException("");
		}
	}
	
	// (送多方修改) (方法註解也有修改)
	/**
	 * 根據Batch集信的業務名稱別和目標檔案名稱,得到被搬移後業務檔的位置(包含確認).
	 * @param targetFilename
	 * @param businessName 業務名稱,如: MST, POS ...
	 * @param sysuhinType
	 * @return [0]: 被搬移後的目標檔  [1]: 被搬移後的確認檔
	 */
	private File[] getMovedPairFilesBySyushinType(String targetFilename, String businessName) {
		File[] fileInfo = new File[2];
		File movedTargetFile = null;
		File movedConfirmationFile = null;
		
		// 取得目標檔
		movedTargetFile = FilePathUtils.multiPathConcat(
								this.syushinBatchTmpPath.getAbsolutePath(),
								businessName,
								targetFilename);
		
		// 取得確認檔
		movedConfirmationFile = ConfirmtaionFileForTxFileParser.getConfirmationFile(movedTargetFile);
		
		fileInfo[0] = movedTargetFile;
		fileInfo[1] = movedConfirmationFile;
		
		return fileInfo;
	}
	
	private File getMessageFileForTxFile(File txFile) {
		return new File(txFile.getAbsolutePath() + this.syushinOkMessageSuffix);
	}
	
	/**
	 * 重新偵測檔案
	 * @param businessName
	 * @param redetectFile
	 * @throws ActionException
	 */
	private void redetectFile(String businessName, File redetectFile) throws ActionException {
		try {
			// throws IOException
			IgxFileUtils.redetectFile(redetectFile);
		} catch (IOException e) {
			// ********************** Log **********************
			IgxLog.messageDetailsLog.error(this, e.getMessage());
			// ********************** Log **********************
			
			// ********************** Log **********************
			IgxLog.messageLog.error(this,
							"SUDA-285 Recovering business'{}' preprocess occured an I/O error in redetecting confirmation file '{}' step.",
							businessName, redetectFile.getAbsolutePath());
			// ********************** Log **********************
			
			throw new ActionException("");
		}
	}
	
	// --- getter and setter ---

	public void setSyushinInboxPathStr(String syushinInboxPathStr) {
		this.syushinInboxPathStr = syushinInboxPathStr;
		this.syushinInboxPath = new File(syushinInboxPathStr);
	}

	public void setSyushinRealOutboxPathStr(String syushinRealOutboxPathStr) {
		this.syushinRealOutboxPathStr = syushinRealOutboxPathStr;
		this.syushinRealOutboxPath = new File(syushinRealOutboxPathStr);
	}

	public void setSyushinBatchTmpPahStr(String syushinBatchTmpPahStr) {
		this.syushinBatchTmpPathStr = syushinBatchTmpPahStr;
		this.syushinBatchTmpPath = new File(syushinBatchTmpPahStr);
	}


	public void setFileOperation(FileOperation fileOperation) {
		this.fileOperation = fileOperation;
	}

	public void setBusinessManager(BusinessManager businessManager) {
		this.businessManager = businessManager;
	}

	public void setBusinessNameForBusinessParser(
			FormatParser businessNameForBusinessParser) {
		this.businessNameForBusinessParser = businessNameForBusinessParser;
	}

	public void setSyushinBusinessMgtDao(
			ISyushinBusinessMgtDao syushinBusinessMgtDao) {
		this.syushinBusinessMgtDao = syushinBusinessMgtDao;
	}
	
	// (送多方新增)
	public void setSyushinBusinessTargetActionDao(
			ISyushinBusinessTargetActionDao syushinBusinessTargetActionDao) {
		this.syushinBusinessTargetActionDao = syushinBusinessTargetActionDao;
	}
	
	// (送多方新增)
	public void setSyushinTerminalIDParser(FormatParser syushinTerminalIDParser) {
		this.syushinTerminalIDParser = syushinTerminalIDParser;
	}
	
	// (送多方新增)
	public void setSyushinOkMessageSuffix(String syushinOkMessageSuffix) {
		this.syushinOkMessageSuffix = syushinOkMessageSuffix;
	}

}
